package com.oss.config;

import java.util.Map;
import java.util.Set;

import com.eova.interceptor.LoginInterceptor;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.oss.demo.DemoFormController;
import com.oss.demo.DemoIconController;
import com.oss.demo.DemoModalController;
import com.oss.demo.DemoOperateController;
import com.oss.demo.DemoReportController;
import com.oss.demo.DemoTableController;
import com.oss.product.ProductController;
import com.oss.test.XlsController;
import com.rock.sys.config.RockMoudleConfig;

public class DemoMoudleConfig extends RockMoudleConfig {

	@Override
	public void routeMoudle(Routes me) {
		System.out.println("demo演示模块加载路由");

		// 自定义的路由配置往这里加。。。
		me.add("/product", ProductController.class);
		me.add("/userInfo", com.oss.user.UserInfoController.class);
		me.add("/xls", XlsController.class);
		LoginInterceptor.excludes.add("/xls/**");

		// 不需要登录拦截的URL
		LoginInterceptor.excludes.add("/init");

		me.add("/demo/form", DemoFormController.class);
		me.add("/demo/table", DemoTableController.class);
		me.add("/demo/modal", DemoModalController.class);
		me.add("/demo/operate", DemoOperateController.class);
		me.add("/demo/report", DemoReportController.class);
		me.add("/demo/icon", DemoIconController.class);
		// LoginInterceptor.excludes.add("/demo/form");

		// end
	}

	@Override
	public void mappingMoudle(ActiveRecordPlugin arp) {
		System.out.println("demo演示模块加载模型");

		// 自定义业务Model映射往这里加 
		arp.addMapping("t_user", com.eova.model.UserInfo.class);
	}

	@Override
	public void authMoudle(Map<Integer, Set<String>> auths) {
		System.out.println("demo演示模块加载权限");

		Set<String> uris = auths.get(0);
		// 此处设置需要用户登录的所有公共权限 uris.add(e)
		auths.put(0, uris);
	}

}